#define _CRT_SECURE_NO_WARNINGS 1
char* replaceSpaces(char* S, int length)
{
    int spacenum = 0;
    for (int i = 0; i < length; i++)
    {
        if (S[i] == ' ')
        {
            spacenum++;
        }
    }
    int length1 = length + spacenum * 2 + 1;
    char* S1 = (char*)calloc(length1, 1);
    int j = 0;
    for (int i = 0; i < length; i++)
    {
        if (S[i] == ' ')
        {
            S1[j++] = '%';
            S1[j++] = '2';
            S1[j++] = '0';
        }
        else
        {
            S1[j++] = S[i];
        }
    }
    return S1;
}